Back-of-the-Envelope Cheatsheet

Napkin math for system design. Use powers of 1000, never apologize for rounding.

1. The core trick: multiply, then count zeros

bytes/item ร— items = total. Work in powers of 10. Every ร—1000 moves you up one unit: B โ†’ KB โ†’ MB โ†’ GB โ†’ TB โ†’ PB. So 3 zeros per step.
UnitBytes (approx)Zeros
1 KB103 = 1,0003
1 MB106 = 1,000,0006
1 GB1099
1 TB101212
1 PB101515

Memorize these anchor products

Per itemร— 1 thousandร— 1 millionร— 1 billion
1 byte1 KB1 MB1 GB
100 bytes100 KB100 MB100 GB
1 KB1 MB1 GB1 TB
1 MB1 GB1 TB1 PB

Sanity check from the interview: 100 bytes ร— 1M users = 100 MB. (Not 100 GB โ€” that would be 100 bytes ร— 1B, or 100 KB ร— 1M.)

2. QPS / throughput conversions

1 day โ‰ˆ 100,000 seconds (actually 86,400, round to 105). So per-day รท 100,000 = per-second.
Volumeโ‰ˆ QPSHow
1 million / day~12 /s106 / 105
10 million / day~120 /sbump one zero
100 million / day~1,200 /s
1 billion / day~12,000 /s109 / 105
1 billion / month~400 /sรท 30 days more

Peak factor: multiply average QPS by ~2โ€“3ร— for peak, and provision for peak.

3. Common datastore sizes (single node, rules of thumb)

Redis (in-memory)

Throughput~100K ops/s
Latency<1 ms
Practical RAM/node25โ€“100 GB
Hard ceilingRAM-bound

It's a cache. If your dataset > RAM you shard, full stop.

Postgres (disk)

Writes/node~5Kโ€“10K/s
Reads (w/ replicas)10s of K/s
Comfortable sizeup to a few TB
Row (rough)~1 KB

Vertical scale + read replicas first. Shard only when writes or size force it.

StoreUse forBallpark cap / node
Redis / Memcachedcache, counters, sessions~100 GB, 100K ops/s
Postgres / MySQLtransactions, relational~few TB, ~10K w/s
Cassandra / Dynamohigh write, wide scalescales horizontally by design
Kafkaevent stream / log~1M+ msg/s (cluster)
S3 / object storeblobs, backupseffectively unbounded

4. When to scale horizontally / shard

Shard when a single node hits any one ceiling: RAM, disk, or throughput. Reach for the cheaper levers first.

5. Latency numbers (order of magnitude)

OperationTimeMental anchor
L1 cache reference~1 nsfree
Main memory (RAM) reference~100 ns100ร— L1
Read 1 MB sequentially from RAM~0.25 ms
SSD random read (4 KB)~150 ยตs~1000ร— RAM
Read 1 MB from SSD~1 ms
Round trip, same datacenter~0.5 msthe Redis hop
Disk seek (spinning)~10 msavoid
Read 1 MB from spinning disk~20 ms
Round trip, cross-region (CAโ†”EU)~100โ€“150 msthe expensive one
Rough ladder: RAM 100 ns โ†’ SSD 100 ยตs โ†’ same-DC network 0.5 ms โ†’ disk seek 10 ms โ†’ cross-region 100 ms. Each rung is roughly 100โ€“1000ร— the last. Memory is ~1Mร— faster than a cross-region hop.

6. Fast facts to keep handy

Time

Sizes of common things

7. Worked example (the pattern to repeat)

Q: 500M daily active users, each posts 2 tweets/day, 300 bytes each. Storage per year?